package com.liu.design.structure.component;

/**
 * @author LIU
 * @version 1.0
 * @date 2024/5/6 14:26
 * @description TODO
 */
public class SingleMinStrategy extends CompositeDiscount{
    /**
     * 多种折扣，选择最低折扣
     * @param price
     * @return
     */
    @Override
    public Double getTotal(double price) {
        Double res = price;
        for (DiscountStrategy strategy : strategies) {
            res = Math.min(res,strategy.getTotal(price));
        }
        return res;
    }
}
